package com.sailfish.springbootdemo.controller.db1;

import com.sailfish.springbootdemo.pojo.Result;
import com.sailfish.springbootdemo.pojo.db1.LineBaseSmallType;
import com.sailfish.springbootdemo.pojo.db1.LineTechSmallType;
import com.sailfish.springbootdemo.service.db1.LineBaseSmallTypeService;
import com.sailfish.springbootdemo.service.db1.LineTechSmallTypeService;
import com.sailfish.springbootdemo.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
@RequestMapping("/lineTechSmallType")
public class LineTechSmallTypeController {

    @Autowired
    private LineTechSmallTypeService lineTechSmallTypeService;

    @PostMapping("/getAllLineTechSmallTypeByBigType")
    public Result getAllLineTechSmallTypeByBigType(String searchValue, Integer lineTechBigTypeId) {
        try {
            return ResultUtil.success(lineTechSmallTypeService.getAllLineTechSmallTypeByBigType(searchValue, lineTechBigTypeId));
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/addOrUpdateLineTechSmallType")
    public Result addOrUpdateLineTechSmallType(LineTechSmallType lineTechSmallType, String mode) {
        return lineTechSmallTypeService.addOrUpdateLineTechSmallType(lineTechSmallType, mode);
    }

    @PostMapping("/deleteLineTechSmallType")
    public Result deleteLineTechSmallType(Integer lineTechSmallTypeId) {
        return lineTechSmallTypeService.deleteLineTechSmallType(lineTechSmallTypeId);
    }
}
